import http from '@/utils/http';

// 习题相关API
export const exerciseApi = {
  // 生成习题
  generateExercises(data) {
    // 返回习题生成API结果
    return http.post('/api/teaching/generate-exercises', data);
  },
  
  // 获取习题列表
  getExercises(params) {
    return http.get('/api/exercises', { params });
  },
  
  // 按条件获取习题
  getExercisesByCondition(subject, grade, topic) {
    return http.get(`/api/exercises/subject/${subject}/grade/${grade}/topic/${topic}`);
  },
  
  // 保存习题到数据库
  saveExercise(exerciseData) {
    return http.post('/api/exercises', exerciseData);
  },
  
  // 获取习题历史记录
  getExerciseHistory() {
    return http.get('/api/exercise-library/history', {
      params: {
        teacherId: localStorage.getItem('teacherId')
      }
    });
  },
  
  // 测试连接
  testConnection() {
    return http.get('/api/teaching/test-connection');
  },
  
  // 获取习题历史记录
  getHistory(teacherId, page, size) {
    return http.get('/api/exercises/history', {
      params: {
        teacherId,
        page,
        size
      }
    });
  },
  
  // 获取单个习题详情
  getExerciseDetail(id) {
    return http.get(`/api/exercises/${id}`);
  }
};

// 考试记录相关API
export const examRecordApi = {
  // 获取学生考试记录
  getStudentExamRecords(studentId) {
    return http.get(`/api/exam-records/student/${studentId}`);
  },
  
  // 添加考试记录
  addExamRecord(data) {
    return http.post('/api/exam-records', data);
  },
  
  // 更新考试记录
  updateExamRecord(data) {
    return http.put('/api/exam-records', data);
  },
  
  // 删除考试记录
  deleteExamRecord(examId) {
    return http.delete(`/api/exam-records/${examId}`);
  }
};

// AI对话相关API
export const chatApi = {
  // 发送消息
  sendMessage(message) {
    return http.post('/api/chat', { message });
  }
};

export default {
  exerciseApi,
  examRecordApi,
  chatApi
}; 